/******************************************************
 *                                                     
 *              Score System               
 *                                                     
 *******************************************************/

/**
 * ViewServlet.java
 *
 * 网页的响应Servlet
 *
 * @author sundy
 * @version 0.0.1
 * lastModified 2011-01-01
 */

package com.sundy.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sundy.core.Context;
import com.sundy.core.Utility;
import com.sundy.tools.ExcelProcess;

public class ViewServlet extends AbstractServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -759384852959469778L;

	public ViewServlet() {
	}

	protected void doGet(Context context, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(context, request, response);
	}

	protected void doPost(Context context, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		if (id == null || id.equals("")) {
			Utility.showError(request, response, "参数错误");
			return;
		}
		String view = ExcelProcess.exportToHtml(Integer.valueOf(id));
		if (view.equals("")) {
			Utility.showError(request, response, "居然没有找到任何预览信息！");
			return;
		}
		request.setAttribute("memo", view);
		Utility.showJSP(request, response, "/view.jsp");
	}
}
